#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <qsettings.h>
#include <QSystemTrayIcon>
#include <qmediaplayer.h>

namespace Ui {
class MainWindow;
}

class DatabaseDialog;
class SettingsDialog;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

public slots:
    void showWindow();

protected:
    void changeEvent(QEvent* e);
    void closeEvent(QCloseEvent* e);

private:
    Ui::MainWindow *ui;

    QSettings m_settings;
    QSystemTrayIcon* m_pSysTray;
    int m_messageShown;
    bool m_quitImmediately;

    QMediaPlayer m_player;
    DatabaseDialog* m_pDbDlg;
    QTimer* m_pDbUpdateTimer;

    SettingsDialog* m_pSettingsDlg;

    QMenu* m_pMenuTray;

    static const QString INI_START_TIME;
    static const QString INI_WORK_TIME;
    static const QString INI_BREAK_TIME;
    static const QString INI_WORK_TIME_FRIDAY;
    static const QString INI_BREAK_TIME_FRIDAY;
    static const QString INI_WARNING_TIME;
    static const QString INI_MINUS_START_TIME;
    static const QString INI_PLUS_END_TIME;

private:
    void installTrayIcon();

private slots:
    void recalculate();
    void showRemaining();
    void sysMenuAction(QSystemTrayIcon::ActivationReason i_reason);
    void quit();
    void saveSettings();
    void showDatabase();
    void showSettings();
    void updateDb();
    void updateTodaysEnd();
};

#endif // MAINWINDOW_H
